package com.tenwives;

import com.tenwives.ashop.kernel.*;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        //TIP Press <shortcut actionId="ShowIntentionActions"/> with your caret at the highlighted text
        // to see how IntelliJ IDEA suggests fixing it.

        List<Special> specials = new ArrayList<>();
        List<Coupon> coupons =  new ArrayList<>();
        List<Fruit>  fruits =  new ArrayList<>();
        fruits.add(new Fruit("苹果",8));
        fruits.add(new Fruit("草莓",13));
        Shop shop = new Shop("一家水果", specials, coupons, fruits);

        Customer customerA = new Customer("A");
        List<Goods>  goodsList = new ArrayList<>();
        goodsList.add(shop.sellFruits("苹果", 5));
        goodsList.add(shop.sellFruits("草莓", 3));
        System.out.println(customerA);
        Trade trade = shop.createTrade(customerA, goodsList);
        System.out.println(trade.getActualPrice());

        shop.loadFruits("芒果", 20);
        Customer customerB = new Customer("B");
        goodsList.clear();
        goodsList.add(shop.sellFruits("苹果", 5));
        goodsList.add(shop.sellFruits("草莓", 3));
        goodsList.add(shop.sellFruits("芒果", 8));
        System.out.println(customerB);
        trade = shop.createTrade(customerB, goodsList);
        System.out.println(trade.getActualPrice());

        shop.offerSpecial(new Special(shop.findFruit("草莓"), new Discount("草莓限时打8折", 0.8), LocalDateTime.now(), LocalDateTime.now().plusDays(10)));
        Customer customerC = new Customer("C");
        goodsList.clear();
        goodsList.add(shop.sellFruits("苹果", 5));
        goodsList.add(shop.sellFruits("草莓", 3));
        goodsList.add(shop.sellFruits("芒果", 8));
        System.out.println(customerC);
        trade = shop.createTrade(customerC, goodsList);
        System.out.println(trade.getActualPrice());

        shop.offerCoupon(new Coupon("购物满100减10块", 100, -10));
        Customer customerD = new Customer("D");
        goodsList.clear();
        goodsList.add(shop.sellFruits("苹果", 5));
        goodsList.add(shop.sellFruits("草莓", 3));
        goodsList.add(shop.sellFruits("芒果", 8));
        System.out.println(customerD);
        trade = shop.createTrade(customerD, goodsList);
        System.out.println(trade.getActualPrice());
    }
}